@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
}
<div class="bg-gray">


	<header class="mui-bar mui-bar-nav head-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href='@Url.Action("Index","User")'></a>
		<h1 class="mui-title">实名认证</h1>
	</header>
	<!--DOM -->
	<div class="mui-content bg-gray">
		<!---->
		<div class="mui-input-group smrz-input-group">
			<div class="mui-input-row">
				<label>真实姓名</label>
				<input type="text" placeholder="请输入真实姓名" class="j-name">
			</div>
			<div class="mui-input-row">
				<label>证件号码</label>
				<input type="text" class="mui-input-clear j-card" placeholder="请输入15位或18位证件号号码">
			</div>
		</div>

		<p style="padding: 0 15px;margin-top: 10px;">证件照片</p>
		<div class="smrz-sfz-box">
			<div class="smrz-input">
				<img src="/images/smrz-img1.png" class="z-img1">
				<input type="hidden" class="v-img1">
				<input type="file" accept="image/*" class="img1" value="" />
			</div>
			<div class="smrz-input">
				<img src="/images/smrz-img2.png" class="z-img2">
				<input type="hidden" class="v-img2">
				<input type="file" accept="image/*" class="img2" value="" />
			</div>
		</div>
		<p style="padding: 0 15px;margin-top: 10px;">驾照认证</p>
		<div class="smrz-sfz-box">
			<div class="smrz-input">
				<img src="/images/smrz-img3.png" class="z-img3">
				<input type="hidden" class="v-img3">
				<input type="file" accept="image/*" class="img3" value="" />
			</div>
			<div class="smrz-input">
				<img src="/images/smrz-img4.png" class="z-img4">
				<input type="hidden" class="v-img4">
				<input type="file" accept="image/*" class="img4" value="" />
			</div>
		</div>
		<br />
		<br />
		<!---->
		<button class="mui-btn mui-btn-block mui-btn-green res-btn">提交审核</button>

		<br />
		<!---->
	</div>

</div>


@section Scripts{
<script>
	layui.use(['form', 'upload'], function() {

		var upload = layui.upload;

		var uploadInst1 = upload.render({
			elem: '.img1',
			url: '@Url.Action("UploadFilesAjax","Login")',
			before: function(obj) {
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result) {
					$(".z-img1").attr("src", result);
				});
			},
			done: function(res) {
				layerm.open({
					content: '上传成功',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				$('.v-img1').val(res.data.src);
				//上传成功
			},
			error: function() {
				//信息框
				layerm.open({
					content: '上传失败，请联系我们或者稍后重试',
					btn: '好的'
				});
			}
		});

		var uploadInst2 = upload.render({
			elem: '.img2',
			url: '@Url.Action("UploadFilesAjax","Login")',
			before: function(obj) {
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result) {
					$(".z-img2").attr("src", result);
				});
			},
			done: function(res) {
				layerm.open({
					content: '上传成功',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				$('.v-img2').val(res.data.src);
				//上传成功
			},
			error: function() {
				//信息框
				layerm.open({
					content: '上传失败，请联系我们或者稍后重试',
					btn: '好的'
				});
			}
		});

		var uploadInst3 = upload.render({
			elem: '.img3',
			url: '@Url.Action("UploadFilesAjax","Login")',
			before: function(obj) {
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result) {
					$(".z-img3").attr("src", result);
				});
			},
			done: function(res) {
				layerm.open({
					content: '上传成功',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				$('.v-img3').val(res.data.src);
				//上传成功
			},
			error: function() {
				//信息框
				layerm.open({
					content: '上传失败，请联系我们或者稍后重试',
					btn: '好的'
				});
			}
		});

		var uploadInst4 = upload.render({
			elem: '.img4',
			url: '@Url.Action("UploadFilesAjax","Login")',
			before: function(obj) {
				//预读本地文件示例，不支持ie8
				obj.preview(function(index, file, result) {
					$(".z-img4").attr("src", result);
				});
			},
			done: function(res) {
				layerm.open({
					content: '上传成功',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				$('.v-img4').val(res.data.src);
				//上传成功
			},
			error: function() {
				//信息框
				layerm.open({
					content: '上传失败，请联系我们或者稍后重试',
					btn: '好的'
				});
			}
		});
	});
	
	$(".res-btn").click(function () {
		if($(".j-name").val().length==0){
			layerm.open({
				content: '请输入姓名',
				btn: '好的'
			});
			return false;
		}
		if($(".j-card").val().length<15||$(".j-card").val().length>18){
			layerm.open({
				content: '请输入真是的身份证号码',
				btn: '好的'
			});
			return false;
		}
		
		if ($(".v-img1").val().length==0&&$(".v-img3").val().length==0) {
			layerm.open({
				content: '请至少上传一种类型的照片',
				btn: '好的'
			});
			return false;
		}
		if ($(".v-img2").val().length==0&&$(".v-img4").val().length==0) {
			layerm.open({
				content: '请至少上传一种类型的照片',
				btn: '好的'
			});
			return false;
		}
		
		$.ajax({
			type:"post",
			url:'@Url.Action("AjaxRenZhane")',
			data:{
				name:$(".j-name").val(),
				carno:$(".j-card").val(),
				carimgz:$(".v-img1").val(),
				carimgf:$(".v-img2").val(),
				photoz:$(".v-img3").val(),
				photof:$(".v-img4").val()
			},
			success:function(result){
				if(result.state=="ok"){
					layerm.open({
						content: result.msg,
						btn: '确定',
						yes:function () {
							location.href='@Url.Action("Index","User")';
						}
					});
				}else{
					layerm.open({
						content: result.msg,
						btn: '确定'
					});
				}
			}
		})
		
		
		
	})
	
	
</script>
}
